<?php

namespace App\Admin\Repositories;

use App\Models\AgricGoodsCategory as Model;
use Dcat\Admin\Repositories\EloquentRepository;

class AgricGoodsCategory extends EloquentRepository
{
    /**
     * Model.
     *
     * @var string
     */
    protected $eloquentClass = Model::class;

    /**
     * 获得全部分类 select选择器
     * @param int $parentId
     * @param int $level
     * @return mixed
     */
    public static function getList($status = 1)
    {
        $query = \App\Models\AgricGoodsCategory::query();
        if ($status) {
            $query->where('status', $status);
        }

        $cartgory = $query->orderBy('category_sort', 'asc')->get();

        foreach ($cartgory as $cartgoryVal) {
            $res[$cartgoryVal->id] = $cartgoryVal->category_name;
        }

        return $res;
    }
}
